package com.anxin.act.config;

import com.anxin.act.utils.ActIdGen;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 修改activiti的id生成策略
 * @author: liuxiangyu
 * @date: 2020/4/1 11:04
 */
@Configuration
public class MyProcessEngineConfigurator {


    @Bean
    public ProcessEngineConfigurationImpl processEngineConfigurationImpl(ProcessEngineConfigurationImpl processEngineConfigurationImpl){
        //设置ProcessEngineConfigurationImpl里的uuidGenerator
        processEngineConfigurationImpl.setIdGenerator(new ActIdGen());
        //设置DbSqlSessionFactory的uuidGenerator，否则流程id，任务id，实例id依然是用DbIdGenerator生成
        processEngineConfigurationImpl.getDbSqlSessionFactory().setIdGenerator(new ActIdGen());
        return processEngineConfigurationImpl;
    }
}
